package com.trkj.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.servlet.ModelAndView;

import com.trkj.service.HwcDepartmentService;
import com.trkj.service.HwcStaffService;


@Controller
public class YzrLoginController {
	
	@Autowired
	private HwcDepartmentService deptService;
	
	@Autowired
	private	HwcStaffService	staffService;
	
	/**
	 * 登录测试（控制器）
	 * @param account
	 * @param password
	 * @return
	 */
	@RequestMapping("/yzr_login")
	public ModelAndView login(String account,String password){
		boolean pd = staffService.findAccountByStaff(account, password);
		ModelAndView mv = new ModelAndView();
		
		if(pd == true){
			String staffName = staffService.findAccountBySName(account);
			mv.addObject("staffAccount", account);
			mv.addObject("staffPassword", password);
			mv.addObject("staffName",staffName);
			long staffNo =Long.parseLong(account.substring(6));
			mv.addObject("staffNo",staffNo);
			//return "hwc_loginresult";
			
			mv.setViewName("yzr_index");
			
		}else{
			
			//return "yzr_index";
			
			mv.setViewName("yzr_login");
			
		}
		
		return mv;
	} 
	
	@RequestMapping("/to_login")
	public String toLogin(){
		return "yzr_login";
	}
}